package utils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class ConfigurationFile implements Comparable {
	
	private String champs;
	private long maxsize;
	private boolean isRequired;
	private char type;
	private int position;
	
	private ConfigurationFile(String champs, long maxsize, boolean isRequired, char type, int position) {
		super();
		this.setChamps(champs);
		this.maxsize = maxsize;
		this.isRequired = isRequired;
		this.type = type;
		this.position = position;
	}

	private ConfigurationFile() {
		this(null,0,false,(char)0,0);
	}
	
	public static List<ConfigurationFile> initConfigurationFile(){
		List<ConfigurationFile> configurationFile = new  ArrayList<ConfigurationFile>();
		configurationFile.add(new ConfigurationFile("matière", 80, true, 'C', 0));
		configurationFile.add(new ConfigurationFile("description", 255, true, 'C', 1));
		configurationFile.add(new ConfigurationFile("formation concernée", 80, true, 'C', 2));
		configurationFile.add(new ConfigurationFile("date de début", 0, true, 'D', 3));
		configurationFile.add(new ConfigurationFile("date de fin", 0, true, 'D', 4));
		configurationFile.add(new ConfigurationFile("durée", 0, true, 'N', 5));
		Collections.sort(configurationFile);
		return configurationFile;
	}
	
	@Override
	public int compareTo(Object other) { 
		int nombre1 = ((ConfigurationFile) other).getPosition(); 
		int nombre2 = this.getPosition(); 
		if (nombre1 > nombre2)  return -1; 
			else if(nombre1 == nombre2) return 0; 
			else return 1; 
	} 

	public long getMaxsize() {
		return maxsize;
	}

	public void setMaxsize(long maxsize) {
		this.maxsize = maxsize;
	}

	public boolean isRequired() {
		return isRequired;
	}

	public void setRequired(boolean isRequired) {
		this.isRequired = isRequired;
	}

	public char getType() {
		return type;
	}

	public void setType(char type) {
		this.type = type;
	}

	public int getPosition() {
		return position;
	}

	public void setPosition(int position) {
		this.position = position;
	}

	public String getChamps() {
		return champs;
	}

	public void setChamps(String champs) {
		this.champs = champs;
	}	
}
